<?php
/**
 * Created by PhpStorm.
 * User: zhao
 * Date: 2018/5/21
 * Time: 16:37
 */

namespace App\Obersvers;


use App\Models\CreditsRecod;
use App\Models\SigninShareRecord;

class SigninRecordObersver
{
    public function created(SigninShareRecord $shareRecord)
    {
        $rule = json_decode($shareRecord->signin_rule,true);
        $credits_record_data['id_wxuser_mcard'] = $shareRecord->id_wxuser_mcard;
        $credits_record_data['id_merchant'] = $shareRecord->id_merchant;
        $credits_record_data['value'] = $rule['credits_one'];
        $credits_record_data['table_type'] = 'signin_share_record';
        $credits_record_data['table_id'] = $shareRecord->id;
        $credits_record_data['title'] = '签到有礼';
        $credits_record_data['desc'] = '签到返积分';
        $time = now()->toDateTimeString();
        $credits_record_data['created_at'] = $time;
        $credits_record_data['updated_at'] = $time;

        CreditsRecod::create($credits_record_data);
    }
}